<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>重点ajax</title>
		<script src="./js/jQurey.js"></script>
	</head>
	<body>
		<div>商品编号:<span id="itemId"></span></div>
		<div>商品编号:<span id="itemPrice"></span></div>
	</body>
</html>
<script>
	/**
	 * jquery 提供ajax,参数是一个js对象{}
	 *  "https://p.3.cn/prices/mgets?skuIds=J_100008348542"
	 */
	//重点 * 并会写
	$.ajax({
		type:"POST",  //发起一个POST请求 	//GET
		url:"http://p.3.cn/prices/mgets",
		data:{
			"skuIds":"100009989503" //商品iqoo 7 
		},
		contentType:"application/json;charest=utf-8",
		//jsonp 跨域
		dataType:"jsonponed",//简写jsonp  json不能跨域  error Access
		//data 和上面没点关系,上面是请求
		success:function(data){
			console.log("访问成功")
			console.log(data)
			
			//解析id和price
			var item = data[0];
			
			var itemId = item.id;
			var itemPrice = item.p;
			console.log(itemId);
			console.log(itemPrice);
			
			var id = $("#itemId");
			id.text(itemId);
			id.css("color","blue");
			
			var price = $("#itemPrice")
			price.text( itemPrice);
			price.css("color","red");
		},
		error:function( e ){
			console.log("访问失败")
		}
	})
</script>